//换验证码
function changeCode() {
	var img = $('#imgCode');
	var ran = Math.random() * 1000;
	img.attr('src', '/code?randomcode=' + ran);
}

// 检验订单
// 检验身份证
function checkNo(obj) {
	var number = $(obj).val();
	var oid = $(obj).attr("id");
	var soid = oid.split('_');
	var type = $("#type_" + soid[1] + "_" + soid[2]).val();
	if (type == "身份证") {
		if (number.length == 18) {
			var sex = number.substring(16, 17);
			var year = number.substring(6, 10);
			var month = number.substring(10, 12);
			var day = number.substring(12, 14);

			if (sex % 2 == 0) {
				$("#gender_" + soid[1] + "_" + soid[2] + " option[value='女']")
						.attr('selected', 'selected');
			} else {
				$("#gender_" + soid[1] + "_" + soid[2] + " option[value='男']")
						.attr('selected', 'selected');
			}
			var date = year + "-" + month + "-" + day;
			$("#birth_" + soid[1] + "_" + soid[2]).val(date);
		}
	}
}
// 复制信息
function copyLine(number) {
	var isCheck = $("#aggree_" + number + "").prop("checked");
	if (isCheck) {
		$("#name_1_" + number + "").val($("#name_0_" + number + "").val());
		$(
				"#type_1_" + number + " option[value='"
						+ $("#type_0_" + number + "").val() + "']").attr(
				'selected', 'selected');
		$(
				"#gender_1_" + number + " option[value='"
						+ $("#gender_0_" + number + "").val() + "']").attr(
				"selected", 'selected');
		$("#no_1_" + number + "").val($("#no_0_" + number + "").val());
		$("#birth_1_" + number + "").val($("#birth_0_" + number + "").val());
	}
}
// 添加行
function addAirLine() {
	var arr = $($("tr[id^='tr_']").last()).children("TD");
	var maxline = $(arr[0]).text().trim();

	var number = parseInt(maxline) + 1;

	var content = "<tr id=\"tr_"
			+ number
			+ "\"><td rowspan=\"3\" class=\"line\">"
			+ number
			+ "</td><td>投保人<br /><br />被投保人</td><td><input id=\"name_0_"
			+ number
			+ "\" name=\"no_0_"
			+ number
			+ "\" type=\"text\" size=\"8\" /><input id=\"name_1_"
			+ number
			+ "\" name=\"name_1_"
			+ number
			+ "\"type=\"text\" size=\"8\" /></td><td><select id=\"type_0_"
			+ number
			+ "\" name=\"type_0_"
			+ number
			+ "\"><option value=\"身份证\">身份证</option><option value=\"护照\">护照</option><option value=\"军官证\">军官证</option><option value=\"其他\">其他</option></select><select id=\"type_1_"
			+ number
			+ "\" name=\"type_1_"
			+ number
			+ "\"><option value=\"身份证\">身份证</option><option value=\"护照\">护照</option><option value=\"军官证\">军官证</option><option value=\"其他\">其他</option></select></td><td><input id=\"no_0_"
			+ number
			+ "\" name=\"no_0_"
			+ number
			+ "\" type=\"text\" size=\"20\" onblur=\"checkNo(this);\" onkeyup=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onmouseover=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onbeforepaste=\"clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-zA-Z0-9]/g,''))\" /><input id=\"no_1_"
			+ number
			+ "\" name=\"no_1_"
			+ number
			+ "\" type=\"text\" size=\"20\" onblur=\"checkNo(this);\" onkeyup=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onmouseover=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onbeforepaste=\"clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-zA-Z0-9]/g,''))\" /></td><td><div class=\"input-append date\" data-date=\"@DateTime.Now.AddMonths(-1).ToString('yyyy-MM-dd')\"  data-date-format=\"yyyy-mm-dd\"><input id=\"birth_0_"
			+ number
			+ "\" name=\"birth_0_"
			+ number
			+ "\" type=\"text\" size=\"8\" data-date-format=\"yyyy-mm-dd\" readonly /><span class=\"add-on\"><i class=\"icon-calendar\"></i></span></div><div class=\"input-append date\" data-date=\"@DateTime.Now.AddMonths(-1).ToString('yyyy-MM-dd')\" data-date-format=\"yyyy-mm-dd\"><input id=\"birth_1_"
			+ number
			+ "\" name=\"birth_1_"
			+ number
			+ "\" type=\"text\" size=\"8\" data-date-format=\"yyyy-mm-dd\" readonly /><span class=\"add-on\"><i class=\"icon-calendar\"></i></span></div></td><td><select id=\"gender_0_"
			+ number
			+ "\" name=\"gender_0_"
			+ number
			+ "\"><option value=\"男\" selected=\"selected\">男</option><option value=\"女\">女</option></select><select id=\"gender_1_"
			+ number
			+ "\" name=\"gender_1_"
			+ number
			+ "\"><option value=\"男\" selected=\"selected\">男</option><option value=\"女\">女</option></select></td><td><input id=\"aggree_"
			+ number
			+ "\" name=\"aggree_"
			+ number
			+ "\" type=\"checkbox\" onclick=\"copyLine('"
			+ number
			+ "');\" />是被保人本人</td></tr><tr><td>被投保人电话</td><td>生效日期</td><td>航班号</td><td>电子邮箱</td><td colspan=\"3\">购买份数</td></tr><tr><td><input type=\"text\" id=\"tel_"
			+ number
			+ "\" size=\"15\" /></td><td><div class=\"input-append date\" data-date=\"@DateTime.Now.AddMonths(-1).ToString('yyyy-MM-dd')\" data-date-format=\"yyyy-mm-dd\"><input type=\"text\" id=\"active_"
			+ number
			+ "\" size=\"8\" data-date-format=\"yyyy-mm-dd\" readonly /><span class=\"add-on\"><i class=\"icon-calendar\"></i></span></div></td><td><input type=\"text\" id=\"flight_"
			+ number
			+ "\" size=\"15\" /></td><td><input type=\"text\" id=\"email_"
			+ number
			+ "\" /></td><td colspan=\"2\"><select id=\"num_"
			+ number
			+ "\" name=\"num_"
			+ number
			+ "\"><option value=\"1\">1份</option><option value=\"2\">2份</option></select></td><td><a onclick=\"delLine(this);\" style=\"cursor:pointer;\">删除</a></td></tr>";
	$("#personList").append(content);
	$('.input-append').datepicker();
}

// 添加行
function addTravelLine() {
	var arr = $($("tr[id^='tr_']").last()).children("TD");
	var maxline = $(arr[0]).text().trim();

	var number = parseInt(maxline) + 1;

	var content = "<tr id=\"tr_"
			+ number
			+ "\"><td rowspan=\"3\" class=\"line\">"
			+ number
			+ "</td><td>投保人<br /><br />被投保人</td><td><input id=\"name_0_"
			+ number
			+ "\" name=\"no_0_"
			+ number
			+ "\" type=\"text\" size=\"8\" /><input id=\"name_1_"
			+ number
			+ "\" name=\"name_1_"
			+ number
			+ "\"type=\"text\" size=\"8\" /></td><td><select id=\"type_0_"
			+ number
			+ "\" name=\"type_0_"
			+ number
			+ "\"><option value=\"身份证\">身份证</option><option value=\"护照\">护照</option><option value=\"军官证\">军官证</option><option value=\"其他\">其他</option></select><select id=\"type_1_"
			+ number
			+ "\" name=\"type_1_"
			+ number
			+ "\"><option value=\"身份证\">身份证</option><option value=\"护照\">护照</option><option value=\"军官证\">军官证</option><option value=\"其他\">其他</option></select></td><td><input id=\"no_0_"
			+ number
			+ "\" name=\"no_0_"
			+ number
			+ "\" type=\"text\" size=\"20\" onblur=\"checkNo(this);\" onkeyup=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onmouseover=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onbeforepaste=\"clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-zA-Z0-9]/g,''))\" /><input id=\"no_1_"
			+ number
			+ "\" name=\"no_1_"
			+ number
			+ "\" type=\"text\" size=\"20\" onblur=\"checkNo(this);\" onkeyup=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onmouseover=\"value=value.replace(/[^a-zA-Z0-9]/g,'')\" onbeforepaste=\"clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-zA-Z0-9]/g,''))\" /></td><td><div class=\"input-append date\" data-date=\"@DateTime.Now.AddMonths(-1).ToString('yyyy-MM-dd')\"  data-date-format=\"yyyy-mm-dd\"><input id=\"birth_0_"
			+ number
			+ "\" name=\"birth_0_"
			+ number
			+ "\" type=\"text\" size=\"8\" data-date-format=\"yyyy-mm-dd\" readonly /><span class=\"add-on\"><i class=\"icon-calendar\"></i></span></div><div class=\"input-append date\" data-date=\"@DateTime.Now.AddMonths(-1).ToString('yyyy-MM-dd')\" data-date-format=\"yyyy-mm-dd\"><input id=\"birth_1_"
			+ number
			+ "\" name=\"birth_1_"
			+ number
			+ "\" type=\"text\" size=\"8\" data-date-format=\"yyyy-mm-dd\" readonly /><span class=\"add-on\"><i class=\"icon-calendar\"></i></span></div></td><td><select id=\"gender_0_"
			+ number
			+ "\" name=\"gender_0_"
			+ number
			+ "\"><option value=\"男\" selected=\"selected\">男</option><option value=\"女\">女</option></select><select id=\"gender_1_"
			+ number
			+ "\" name=\"gender_1_"
			+ number
			+ "\"><option value=\"男\" selected=\"selected\">男</option><option value=\"女\">女</option></select></td><td><input id=\"aggree_"
			+ number
			+ "\" name=\"aggree_"
			+ number
			+ "\" type=\"checkbox\" onclick=\"copyLine('"
			+ number
			+ "');\" />是被保人本人</td></tr><tr><td>被投保人电话</td><td>生效日期</td><td>旅行线路</td><td>电子邮箱</td><td colspan=\"3\">购买份数</td></tr><tr><td><input type=\"text\" id=\"tel_"
			+ number
			+ "\" size=\"15\" /></td><td><div class=\"input-append date\" data-date=\"@DateTime.Now.AddMonths(-1).ToString('yyyy-MM-dd')\" data-date-format=\"yyyy-mm-dd\"><input type=\"text\" id=\"active_"
			+ number
			+ "\" size=\"8\" data-date-format=\"yyyy-mm-dd\" readonly /><span class=\"add-on\"><i class=\"icon-calendar\"></i></span></div></td><td><input type=\"text\" id=\"travel_"
			+ number
			+ "\" size=\"15\" /></td><td><input type=\"text\" id=\"email_"
			+ number
			+ "\" /></td><td colspan=\"2\"><select id=\"num_"
			+ number
			+ "\" name=\"num_"
			+ number
			+ "\"><option value=\"1\">1份</option><option value=\"2\">2份</option></select></td><td><a onclick=\"delLine(this);\" style=\"cursor:pointer;\">删除</a></td></tr>";
	$("#personList").append(content);
	$('.input-append').datepicker();
}

// 删除行
function delLine(obj) {
	$(obj).parent().parent().prev().prev().remove();
	$(obj).parent().parent().prev().remove();
	$(obj).parent().parent().remove();
}
function prepairAirOrder(pid) {
	var arrList = new Array();
	$("tr[id^='tr_']").each(function() {
		var arr = $(this).children("TD");
		var number = $(arr[0]).text().trim();
		arrList.push($("#name_0_" + number).val());
		arrList.push($("#type_0_" + number).val());
		arrList.push($("#no_0_" + number).val());
		arrList.push($("#birth_0_" + number).val());
		arrList.push($("#gender_0_" + number).val());

		arrList.push($("#name_1_" + number).val());
		arrList.push($("#type_1_" + number).val());
		arrList.push($("#no_1_" + number).val());
		arrList.push($("#birth_1_" + number).val());
		arrList.push($("#gender_1_" + number).val());

		arrList.push($("#tel_" + number).val());
		arrList.push($("#active_" + number).val());
		arrList.push($("#num_" + number).val());
		arrList.push($("#flight_" + number).val());
		arrList.push($("#email_" + number).val());
	});
	CreateOrder(arrList, pid);
}

function prepairTravelOrder(pid) {
	var arrList = new Array();
	$("tr[id^='tr_']").each(function() {
		var arr = $(this).children("TD");
		var number = $(arr[0]).text().trim();
		arrList.push($("#name_0_" + number).val());
		arrList.push($("#type_0_" + number).val());
		arrList.push($("#no_0_" + number).val());
		arrList.push($("#birth_0_" + number).val());
		arrList.push($("#gender_0_" + number).val());

		arrList.push($("#name_1_" + number).val());
		arrList.push($("#type_1_" + number).val());
		arrList.push($("#no_1_" + number).val());
		arrList.push($("#birth_1_" + number).val());
		arrList.push($("#gender_1_" + number).val());

		arrList.push($("#tel_" + number).val());
		arrList.push($("#active_" + number).val());
		arrList.push($("#num_" + number).val());
		arrList.push($("#travel_" + number).val());
		arrList.push($("#email_" + number).val());
	});
	CreateOrder(arrList, pid);
}

// 创建订单
function CreateOrder(arrList, productId) {
	$.ajax({
		type : 'POST',
		url : "/order/create.json",
		data : {
			arrList : arrList,
			productId : productId
		},
		success : function(data) {
			if (data && data.ok) {
				// alert(data.msg);
				location.href = "/order/pay?id=" + data.msg;
			} else {
				alert(data.msg);
			}
		}
	});
}

function UploadAirFile() {
	var fileObj = document.getElementById("file").files[0];

	// FormData 对象
	var form = new FormData();
	form.append("file", fileObj);
	form.append("pt", "air");

	// XMLHttpRequest 对象
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (xhr.status == 200 || xhr.status == 0) {
				// 取得返回字符串
				var resp = xhr.responseText;
				// 构造返回JSON对象的方法
				var func = new Function("return " + resp);
				// 得到JSON对象
				var json = func();
				if (json.ok) {
					var arr = $($("tr[id^='tr_']").last()).children("TD");
					var maxline = $(arr[0]).text().trim();
					var number = maxline;
					// 显示返回结果
					$.each(json.data, function(index, item) {
						if (Number(number) > 1) {
							addAirLine();
							number++;
						} else if (Number(index) > 0) {
							addAirLine();
							number = Number(number) + Number(index);
						}
						$("#name_0_" + number).val(item.name);
						$(
								"#type_0_" + number + " option[value='"
										+ item.type + "']").attr('selected',
								'selected');
						$("#no_0_" + number).val(item.no);
						$("#birth_0_" + number).val(item.birth);
						$(
								"#gender_0_" + number + " option[value='"
										+ item.gender + "']").attr('selected',
								'selected');
						$("#name_1_" + number).val(item.name1);
						$(
								"#type_1_" + number + " option[value='"
										+ item.type1 + "']").attr('selected',
								'selected');
						$("#no_1_" + number).val(item.no1);
						$("#birth_1_" + number).val(item.birth1);
						$(
								"#gender_1_" + number + " option[value='"
										+ item.gender1 + "']").attr('selected',
								'selected');
						$("#tel_" + number).val(item.tel);
						$("#active_" + number).val(item.per);
						$("#num_" + number + " option[value='1']").attr(
								'selected', 'selected');
						$("#flight_" + number).val(item.flight);
						$("#email_" + number).val(item.email);
					});
					$("#progressBar").css("visibility", "hidden");
					$("#percentage").css("visibility", "hidden");
				} else
					alert("数据错误");
			}
		}
	};
	xhr.open("post", "/order/upload.json", true);
	xhr.onload = function() {
		alert("上传完成");
	};
	$("#progressBar").css("visibility", "");
	$("#percentage").css("visibility", "");
	xhr.upload.addEventListener("progress", progressFunction, false);

	xhr.send(form);
}

function UploadTravelFile() {
	var fileObj = document.getElementById("file").files[0];

	// FormData 对象
	var form = new FormData();
	form.append("file", fileObj);
	form.append("pt", "travel");

	// XMLHttpRequest 对象
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4) {
			if (xhr.status == 200 || xhr.status == 0) {
				// 取得返回字符串
				var resp = xhr.responseText;
				// 构造返回JSON对象的方法
				var func = new Function("return " + resp);
				// 得到JSON对象
				var json = func();
				if (json.ok) {
					var arr = $($("tr[id^='tr_']").last()).children("TD");
					var maxline = $(arr[0]).text().trim();
					var number = maxline;
					// 显示返回结果
					$.each(json.data, function(index, item) {
						if (Number(number) > 1) {
							addTravelLine();
							number++;
						} else if (Number(index) > 0) {
							addTravelLine();
							number = Number(number) + Number(index);
						}
						$("#name_0_" + number).val(item.name);
						$(
								"#type_0_" + number + " option[value='"
										+ item.type + "']").attr('selected',
								'selected');
						$("#no_0_" + number).val(item.no);
						$("#birth_0_" + number).val(item.birth);
						$(
								"#gender_0_" + number + " option[value='"
										+ item.gender + "']").attr('selected',
								'selected');
						$("#name_1_" + number).val(item.name1);
						$(
								"#type_1_" + number + " option[value='"
										+ item.type1 + "']").attr('selected',
								'selected');
						$("#no_1_" + number).val(item.no1);
						$("#birth_1_" + number).val(item.birth1);
						$(
								"#gender_1_" + number + " option[value='"
										+ item.gender1 + "']").attr('selected',
								'selected');
						$("#tel_" + number).val(item.tel);
						$("#active_" + number).val(item.per);
						$("#num_" + number + " option[value='1']").attr(
								'selected', 'selected');
						$("#travel_" + number).val(item.travel);
						$("#email_" + number).val(item.email);
					});
					$("#progressBar").css("visibility", "hidden");
					$("#percentage").css("visibility", "hidden");
				} else
					alert("数据错误");
			}
		}
	};
	xhr.open("post", "/order/upload.json", true);
	xhr.onload = function() {
		alert("上传完成");
	};
	$("#progressBar").css("visibility", "");
	$("#percentage").css("visibility", "");
	xhr.upload.addEventListener("progress", progressFunction, false);

	xhr.send(form);
}

function progressFunction(evt) {
	var progressBar = document.getElementById("progressBar");
	var percentageDiv = document.getElementById("percentage");
	if (evt.lengthComputable) {
		progressBar.max = evt.total;
		progressBar.value = evt.loaded;
		percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100)
				+ "%";
	}
}
// 取消订单
function CancelOrder(orderId) {
	if (confirm("是否取消该订单？")) {
		$.getJSON("/order/cancel.json", {
			orderId : orderId
		}, function(data) {
			if (data && data.ok) {
				location.href = "/order/detail?id=" + orderId;
			} else {
				alert("取消失败");
			}
		});
	}
}
// 支付订单
function payOrder(orderId) {
	location.href = "/order/pay?id=" + orderId;
}
// 退保
function cancelPolicy(policyNo) {
	if (confirm("是否确认退保？")) {
		$.getJSON("/policy/cancel.json", {
			policyNo : policyNo
		}, function(data) {
			if (data && data.ok) {
				alert("退保成功");
				window.location.reload();
				// location.href = "/policy/list";
			} else {
				alert(data.msg);
			}
		});
	}
}

// 注册
function submitCust() {
	var name = $.trim($("#userid").val());
	var pwd = $.trim($("#userpwd").val());
	var email = $.trim($("#email").val());
	var contactName = $.trim($("#name").val());
	var contactTel = $.trim($("#tel").val());
	var contactOthers = $.trim($("#other").val());
	var companyName = $.trim($("#company").val());
	var companyZip = $.trim($("#mailcode").val());
	var companyAddress = $.trim($("#address").val());
	var companyTel = $.trim($("#companyTel").val());
	var companyWebsite = $.trim($("#companyUrl").val());
	var companyReg = $.trim($("#compaynNum").val());
	var chargeName = $.trim($("#manger").val());
	var from = $('input[name="from"]:checked').val();
	$.ajax({
		type : 'POST',
		url : "/reg/useradd.json",
		dataType : "json",
		data : {
			name : name,
			pwd : pwd,
			email : email,
			contactName : contactName,
			contactTel : contactTel,
			contactOthers : contactOthers,
			companyName : companyName,
			companyZip : companyZip,
			companyAddress : companyAddress,
			companyTel : companyTel,
			companyWebsite : companyWebsite,
			companyReg : companyReg,
			chargeName : chargeName,
			from : from
		},
		success : function(data) {
			if (data && data.ok) {
				alert("注册成功！");
				window.location.href = "/";
			} else {
				alert(data.msg);
			}
		},
		error : function(error) {
			alert("注册失败！");
		}
	});
}

// 修改用户信息
function submitCustModify(id) {
	if (confirm("是否确定修改？")) {
		var pwd = $.trim($("#pwd").val());
		var email = $.trim($("#email").val());
		var level = $.trim($("#level").val());
		var usefulFee = $.trim($("#usefulFee").val());
		var status = $.trim($("#status").val());
		var userFlg = $("#userFlg").is(':checked') ? 1 : 0;
		var contactName = $.trim($("#contactName").val());
		var contactTel = $.trim($("#contactTel").val());
		var contactOthers = $.trim($("#contactOthers").val());
		var companyName = $.trim($("#companyName").val());
		var companyZip = $.trim($("#companyZip").val());
		var companyAddress = $.trim($("#companyAddress").val());
		var companyTel = $.trim($("#companyTel").val());
		var companyFax = $.trim($("#companyFax").val());
		var companyEmail = $.trim($("#companyEmail").val());
		var companyWebsite = $.trim($("#companyWebsite").val());
		var companyReg = $.trim($("#companyReg").val());
		var chargeName = $.trim($("#chargeName").val());
		var from = $('input[name="from"]:checked').val();
		$.ajax({
			type : 'POST',
			url : "/oem/usermodify.json",
			dataType : "json",
			data : {
				id : id,
				pwd : pwd,
				email : email,
				level : level,
				usefulFee : usefulFee,
				status : status,
				userFlg : userFlg,
				contactName : contactName,
				contactTel : contactTel,
				contactOthers : contactOthers,
				companyName : companyName,
				companyZip : companyZip,
				companyAddress : companyAddress,
				companyTel : companyTel,
				companyFax : companyFax,
				companyEmail : companyEmail,
				companyWebsite : companyWebsite,
				companyReg : companyReg,
				chargeName : chargeName,
				from : from
			},
			success : function(data) {
				if (data && data.ok)
					alert("修改成功！");
				else {
					alert(data.msg);
				}
			},
			error : function(error) {
				alert("修改失败！");
			}
		});
	}
}

// 修改用户等级
function modifyLevel(id) {
	if (confirm("是否确定修改？")) {
		var name = $.trim($("#name_" + id).val());
		var discount = $.trim($("#discount_" + id).val());
		$.ajax({
			type : 'POST',
			url : "/oem/levelmodify.json",
			dataType : "json",
			data : {
				id : id,
				name : name,
				discount : discount
			},
			success : function(data) {
				if (data && data.ok)
					alert("修改成功！");
				else {
					alert(data.msg);
				}
			},
			error : function(error) {
				alert("修改失败！");
			}
		});
	}
}

// 添加等级
function addLevel() {
	if (confirm("是否确定添加等级？")) {
		var name = $.trim($("#lname").val());
		var discount = $.trim($("#discount").val());
		if (name == "" || discount == "") {
			alert("请输入等级名称和折扣！");
			return;
		}
		$.ajax({
			type : 'POST',
			url : "/oem/leveladd.json",
			dataType : "json",
			data : {
				name : name,
				discount : discount
			},
			success : function(data) {
				if (data && data.ok) {
					alert("添加成功！");
					window.location.reload();
				} else {
					alert(data.msg);
				}
			},
			error : function(error) {
				alert("添加失败！");
			}
		});
	}
}

H = {};
H.app = {};
H.app.center = H.app.center || {};
H.app.center.order = {
	orderinit : function() {
		$("table .js_policy_problem")
				.hover(
						function() {
							var a = $(this), b = a.parent();
							clearTimeout(a.data("timer"));
							b.addClass("status_layout_on");
							if (!a.data("requested")) {
								var c = '<table class="table_info" style="width:100%"><thead><tr><td>问题描述</td></tr></thead><tbody class="js_tbody"><tr><td style="text-align:center;padding:5px">正在请求，请稍侯...</td></tr></tbody><tfoot class="js_tfooter" style="display:none"><tr><td></td></tr></tfoot></table>';
								b.find(".order_box .layout_bd").html(c);
								a.data("requested", true);
								b.find(".layout_popup").unbind("mouseenter")
										.unbind("mouseleave").hover(function() {
											clearTimeout(a.data("timer"));
											b.addClass("status_layout_on");
										}, function() {
											b.removeClass("status_layout_on");
										});
								$.ajax({
									type : "get",
									url : "/policy/view_problem.json?pid="
											+ a.attr("policy_id") + "&oid="
											+ a.attr("order_id"),
									timeout : 1000 * 10,
									dataType : "json",
									success : function(g) {
										var l = "", m = "", e = null;
										if (g && g.ok) {
											l = "<tr><td>" + g.msg
													+ "</td></tr>";
										} else {
											l = '<tr><td>'
													+ (g.msg || "查询问题描述失败")
													+ "</td></tr>";
										}
										b.find(".order_box .js_tbody").html(l);
									},
									error : function() {
										a.data("requested", false);
									}
								});
							}
						}, function() {
							var a = $(this);
							clearTimeout(a.data("timer"));
							var b = setTimeout(function() {
								a.parent().removeClass("status_layout_on");
							}, 100);
							a.data("timer", b);
						});
		$("table .js_order_address")
				.hover(
						function() {
							var a = $(this), b = a.parent();
							clearTimeout(a.data("timer"));
							b.addClass("status_layout_on");
							if (!a.data("requested")) {
								var c = '<table class="table_info" style="width:100%"><colgroup><col class="col1"><col class="col2"><col class="col3"><col class="col4"><col class="col5"></colgroup><thead><tr><td>省份</td><td>城市/区</td><td>地址</td><td>联系人</td><td>联系电话</td></tr></thead><tbody class="js_tbody"><tr><td style="text-align:center;padding:5px" colspan="5">正在请求，请稍侯...</td></tr></tbody><tfoot class="js_tfooter" style="display:none"><tr><td></td></tr></tfoot></table>';
								b.find(".order_box .layout_bd").html(c);
								a.data("requested", true);
								b.find(".layout_popup").unbind("mouseenter")
										.unbind("mouseleave").hover(function() {
											clearTimeout(a.data("timer"));
											b.addClass("status_layout_on");
										}, function() {
											b.removeClass("status_layout_on");
										});
								$.ajax({
									type : "get",
									url : ajaxUrl
											+ "?oper=GetOrderAddress&oid="
											+ a.attr("order_id"),
									timeout : 1000 * 10,
									dataType : "json",
									success : function(g) {
										var l = "", m = "", e = null;
										if (g && g.msg == "suc") {
											var j = g.data;
											$.each(j, function(index, item) {
												l += "<tr><td>" + item.province
														+ "</td><td>"
														+ item.city
														+ "</td><td>"
														+ item.address
														+ "</td><td>"
														+ item.contact
														+ "</td><td>"
														+ item.tel
														+ "</td></tr>";
											});
										} else {
											l = '<tr><td colspan="5">'
													+ (g.data || "查询配送地址失败")
													+ "</td></tr>";
										}
										b.find(".order_box .js_tbody").html(l);
									},
									error : function() {
										a.data("requested", false);
									}
								});
							}
						}, function() {
							var a = $(this);
							clearTimeout(a.data("timer"));
							var b = setTimeout(function() {
								a.parent().removeClass("status_layout_on");
							}, 100);
							a.data("timer", b);
						});
		$("table .js_order_fedex")
				.hover(
						function() {
							var a = $(this), b = a.parent();
							clearTimeout(a.data("timer"));
							b.addClass("status_layout_on");
							if (!a.data("requested")) {
								var c = '<table class="table_info" style="width:100%"><thead><tr><td>物流公司</td><td>物流单号</td></tr></thead><tbody class="js_tbody"><tr><td style="text-align:center;padding:5px" colspan="2">正在请求，请稍侯...</td></tr></tbody><tfoot class="js_tfooter" style="display:none"><tr><td></td></tr></tfoot></table>';
								b.find(".order_box .layout_bd").html(c);
								a.data("requested", true);
								b.find(".layout_popup").unbind("mouseenter")
										.unbind("mouseleave").hover(function() {
											clearTimeout(a.data("timer"));
											b.addClass("status_layout_on");
										}, function() {
											b.removeClass("status_layout_on");
										});
								$.ajax({
									type : "get",
									url : ajaxUrl + "?oper=GetOrderFedex&oid="
											+ a.attr("order_id"),
									timeout : 1000 * 10,
									dataType : "json",
									success : function(g) {
										var l = "", m = "", e = null;
										if (g && g.msg == "suc") {
											var j = g.data;
											$.each(j, function(index, item) {
												l += "<tr><td>" + item.company
														+ "</td><td>" + item.no
														+ "</td></tr>";
											});
										} else {
											l = '<tr><td colspan="2">'
													+ (g.data || "查询物流信息失败")
													+ "</td></tr>";
										}
										b.find(".order_box .js_tbody").html(l);
									},
									error : function() {
										a.data("requested", false);
									}
								});
							}
						}, function() {
							var a = $(this);
							clearTimeout(a.data("timer"));
							var b = setTimeout(function() {
								a.parent().removeClass("status_layout_on");
							}, 100);
							a.data("timer", b);
						});
	}
};
